package org.libraq.hrm.fallback;

import org.libraq.hrm.feign.LoginFeignClient;
import org.libraq.hrm.to.LoginMealTo;
import org.libraq.hrm.to.LoginTo;
import org.libraq.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFeignFallbackFactory implements FallbackFactory<LoginFeignClient>{
    @Override
    public LoginFeignClient create(Throwable throwable) {
        return new LoginFeignClient() {
            @Override
            public AjaxResult save(LoginTo to) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("服务降级了！Auth服务不可用！");
            }

            @Override
            public AjaxResult saveLoginMeal(LoginMealTo to) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("服务降级了！Auth服务不可用！");
            }
        };
    }
}
